package alitaV.old;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;

import java.lang.reflect.Field;

public class genericExp1 {
    public static void main(String[] args) throws  Exception{
        System.out.println(gen(String.class));
        System.out.println(gen(Double.class));
    }

    public  static <X> X gen(Class<X> s) throws Exception{
        X x = null;
        if (s.isAssignableFrom(String.class)){
            x = (X)RandomStringUtils.randomAlphabetic(3);
        }
        if (s.isAssignableFrom(Double.class)){
            Double v = RandomUtils.nextDouble();
            x = (X)v;
        }
        return x;
    }

}


